﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace project4
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入数组的行数");
            int M = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入数组的列数");
            int N = int.Parse(Console.ReadLine());
            int[,] matrix = new int[M,N];
            for (int i = 0; i < M; i++)
            {
                string str = Console.ReadLine();//首先输入一字符串，表示二维数组的一行数据
                string[] tmp = str.Split(" ".ToCharArray());//通过Split方法以空格作为分隔符将输入的一行字符串分隔开
                for (int j = 0; j < N; j++)
                {
                    matrix[i, j] = int.Parse(tmp[j]);//将分割后的字符付给二维数组每个元素
                }
            }

            testmatrix test1 = new testmatrix();
            if (test1.testfun(matrix) == true)
            {
                Console.WriteLine("True");
            }
            else
            {
                Console.WriteLine("False");
            }
            Console.ReadKey();

        }
    }

    class testmatrix
    {
        public bool testfun(int[,] matrix)
        {
            for(int i = 0; i < matrix.GetLength(0)-1;i++)
            {
                for(int j = 0; j < matrix.GetLength(1)-1; j++)
                {
                    if (matrix[i,j] != matrix[i + 1,j + 1])
                    {
                        //Console.WriteLine("{0},{1}", i, j);
                        return false;
                    }
                }
            }
            return true;
        }
    }

}
